<?php
# $Id: get_ganglia.php 589 2005-10-10 07:42:26Z knobi1 $
# Retrieves and parses the XML output from gmond. Results stored
# in global variables: $clusters, $hosts, $hosts_down, $metrics.
# Assumes you have already called get_context.php.
#

if (! ganglia_Gmetad($ganglia_ip, $ganglia_port) )
   {
      print "<H4>There was an error collecting ganglia data ".
         "($ganglia_ip:$ganglia_port): $ganglia_error</H4>\n";
      exit;
   }

# If we have no child data sources, assume something is wrong.
if (!count($ganglia_grid) and !count($ganglia_cluster))
   {
      print "<H4>Ganglia cannot find a data source. Is gmond running?</H4>";
      exit;
   }

# If we only have one cluster source, suppress MetaCluster output.
if (count($ganglia_grid) == 2 and $ganglia_context=="meta")
   {
      # Lets look for one cluster (the other is our grid).
      foreach($ganglia_grid as $source)
         if (isset($source['CLUSTER']) and $source['CLUSTER'])
            {
               $standalone = 1;
               $ganglia_context = "cluster";
               # Need to refresh data with new context.
               ganglia_Gmetad($ganglia_ip, $ganglia_port);
               $ganglia_clustername = $source['NAME'];
            }
   }


